package com.master5.grocerylist.credentials;

import java.net.URI;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;

public class CredentialsAlternativeClient {

	public static void main(String[] args) {
		ClientConfig config = new DefaultClientConfig();
		Client client = Client.create(config);
		WebResource service = client.resource(getBaseURI());
		String name = "yigit", password = "bekir";
		Credentials result = service.path("api").path("login").path("auth").path(name).path(password)
				.accept(MediaType.APPLICATION_JSON).get(Credentials.class);
		
		System.out.println("name =" + result.getUserName());
		System.out.println("password=" + result.getPassword());
	}

	private static URI getBaseURI() {
		return UriBuilder.fromUri(
				"http://grocerylistserv.appspot.com").build();
	}

}
